import { onLoad } from 'uni-composition-api'
import { ref } from '@vue/composition-api'
import getCurrentComponent from '@/utils/get-current-component'

export function useRouter() {
  const vm: any = getCurrentComponent()

  return vm.$Router
}

export function useRoute() {
  const query = ref({})
  const vm: any = getCurrentComponent()

  onLoad(() => {
    query.value = vm.$Route.query
  })

  return query
}
